This AppleScript requires Tex-Edit Plus to work.  The purpose of the script is to convert VoodooPad's currently selected text into a highly simplified block of HTML code.  The entire selection is rendered as plain text, except for the links. The links are wrapped in a properly formatted HTML link tag, either with or without a path to the location of your HTML export. 

Note that external URL links are handled appropriately, but External URL aliases will end up linking to a non-existent page. If you manually associate external links to individual words (aliases) in your VoodooPad document, this script probably won't help you.

Please note that this script uses the odd characters "µ" and "Ω" which should look like a horseshoe turned up, and one turned down. (they are the greek letters mu & omega)  If this doesn't appear correctly in your browser, you'll need to replace them with two unique characters that you don't typically use in your VoodooPad document.

Due to technical limitations, the script isn't formatted as code on this page. (see above) It should compile, however, although your mileage may vary. (make sure the quotes are stupefied)



on trim(theSource)
	set thePath to "http://homepage.mac.com/USERNAME/wiki/"
	(* 
Change the preceding line to the path (either local or remote) of your 
VoodooPad HTML Export (Don't forget the trailing "/").  If the selection and
HTML will be used in the same directory, you can change this to "" (blank).
*)
	set the comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	set the source_string to "abcdefghijklmnopqrstuvwxyz"
	set newFile to ""
	repeat with thisChar in theSource
		set x to the offset of thisChar in the comparison_string
		if x is not 0 then
			set the newFile to (the newFile & character x of the source_string) as string
		else
			set the newFile to (the newFile & thisChar) as string
		end if
	end repeat
	set AppleScript's text item delimiters to " "
	set newFile to (text items of newFile)
	set AppleScript's text item delimiters to "_20"
	set newFile to newFile as text
	set AppleScript's text item delimiters to ""
	try
		set newFile to (characters 1 thru 23 of newFile)
	end try
	set newFile to "<a href=\"" & (thePath & newFile & ".html") & "\">" as text
end trim
tell application "VoodooPad"
	activate
	tell application "System Events" to keystroke "c" using command down
end tell
set AppleScript's text item delimiters to "Ω"
tell application "Tex-Edit Plus"
	activate
	make new document at front
	tell application "System Events" to keystroke "v" using command down
	tell document 1
		replace looking for "^*" looking for styles {style:underline} replacing with "Ωµ^*Ω"
		set thebin to contents as text
	end tell
end tell
set thebin to text items of thebin
set thebin to thebin as list
repeat with x from (count of text items of thebin) to 1 by -1
	if item x of thebin starts with "µ" then
		if item x of thebin starts with "µhttp://" then
			set item x of thebin to "<a href=\"" & (item x of thebin) & "\">" & item x of thebin & "</a>"
		else
			set item x of thebin to trim(item x of thebin) & item x of thebin & "</a>"
		end if
	end if
end repeat
set AppleScript's text item delimiters to ""
tell application "Tex-Edit Plus"
	tell document 1
		set contents of document 1 to thebin as text
		replace looking for "µ" replacing with ""
		set style of contents to plain
		set color of contents to black
		set size of contents to 10
		set font of contents to "Monaco"
	end tell
end tell